package com.azusa.xbiao.entity;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@IdClass(CartPK.class)
public class Cart {
    private int id;
    private int gIds;
    private int isPay;
    private String goodsImage;
    private String gType;
    private BigDecimal price;
    private Integer count;
    private Date addDate;

    @Id
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Id
    @Column(name = "g_ids", nullable = false)
    public int getgIds() {
        return gIds;
    }

    public void setgIds(int gIds) {
        this.gIds = gIds;
    }

    @Id
    @Column(name = "is_pay", nullable = false)
    public int getIsPay() {
        return isPay;
    }

    public void setIsPay(int isPay) {
        this.isPay = isPay;
    }

    @Basic
    @Column(name = "goods_image", nullable = true, length = 255)
    public String getGoodsImage() {
        return goodsImage;
    }

    public void setGoodsImage(String goodsImage) {
        this.goodsImage = goodsImage;
    }

    @Basic
    @Column(name = "g_type", nullable = true, length = 255)
    public String getgType() {
        return gType;
    }

    public void setgType(String gType) {
        this.gType = gType;
    }

    @Basic
    @Column(name = "price", nullable = true, precision = 2)
    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    @Basic
    @Column(name = "count", nullable = true)
    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    @Basic
    @Column(name = "add_date", nullable = true)
    public Date getAddDate() {
        return addDate;
    }

    public void setAddDate(Date addDate) {
        this.addDate = addDate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Cart cart = (Cart) o;

        if (id != cart.id) return false;
        if (gIds != cart.gIds) return false;
        if (isPay != cart.isPay) return false;
        if (goodsImage != null ? !goodsImage.equals(cart.goodsImage) : cart.goodsImage != null) return false;
        if (gType != null ? !gType.equals(cart.gType) : cart.gType != null) return false;
        if (price != null ? !price.equals(cart.price) : cart.price != null) return false;
        if (count != null ? !count.equals(cart.count) : cart.count != null) return false;
        if (addDate != null ? !addDate.equals(cart.addDate) : cart.addDate != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + gIds;
        result = 31 * result + (int) isPay;
        result = 31 * result + (goodsImage != null ? goodsImage.hashCode() : 0);
        result = 31 * result + (gType != null ? gType.hashCode() : 0);
        result = 31 * result + (price != null ? price.hashCode() : 0);
        result = 31 * result + (count != null ? count.hashCode() : 0);
        result = 31 * result + (addDate != null ? addDate.hashCode() : 0);
        return result;
    }
}
